package com.beyondbit.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beyondbit.demo.common.IdGenerator;
import com.beyondbit.demo.dao.ArchivetransferMapper;
import com.beyondbit.demo.entity.Archivetransfer;
import com.beyondbit.demo.entity.query.ArchivetransferQuery;
import com.beyondbit.demo.service.ArchivetransferService;
import com.beyondbit.demo.service.BaseUserServiceException;
import org.springframework.stereotype.Service;
import com.beyondbit.web.infrastructure.entity.Page;
import com.github.pagehelper.PageHelper;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service("archivetransferService")
public class ArchivetransferServiceImpl extends ServiceImpl<ArchivetransferMapper, Archivetransfer> implements ArchivetransferService {


    @Resource
    private ArchivetransferMapper archivetransferMapper;

    @Resource
    private IdGenerator idGenerator;

    @Override
    public Page<Archivetransfer> query(ArchivetransferQuery query) {
        PageHelper.startPage(query.getCurrentPage(), query.getPageSize());
        List<Archivetransfer> list = archivetransferMapper.query(query);

        return Page.of(list);
    }

    @Override
    public Archivetransfer get(String id) {
        return archivetransferMapper.get(id);
    }

    @Override
    public void add(Archivetransfer archivetransfer) throws BaseUserServiceException {

             archivetransfer.setId(idGenerator.newId());
             archivetransfer.setGuid(idGenerator.newId());
            archivetransferMapper.add(archivetransfer);

    }

    @Override
    public void update(Archivetransfer archivetransfer) {
            archivetransferMapper.update(archivetransfer);
    }

    @Override
    public void delete(String id) {
            archivetransferMapper.delete(id);
    }

    @Override
    public List<Map<String, Object>> queryDicTypeList(String type) {
        return archivetransferMapper.queryDicTypeList(type);
    }
}